Skip to content

Conversation

@Ecarrion
Copy link
Contributor

Closes: #8071

Why

Prior to this PR, template products where considered unsaved new products, so the preview button was disabled for them.
Here, I'm making sure that a template product is able to be previewed as soon as it is created.

How

  • Added an isEmpty property on EditableProductModel to be able to differentiate a product with content from an empty prroduct.

  • Added a new isNewTemplateProduct on ProductFormViewModel to identify a template product, which is when the original product has id zero and is not not empty.

  • Refactored a bit the shouldEnablePreviewButton() because I found it hard to read 😇

Demo

Preview Template

Dont.Preview.Blank.mov

Disable preview on empty products

Preview.Template.mov

Testing

Note

The feature is currently only visible to users in the experiment treatment group. In the Audience section of the template experiment model, go to Variations > Manual Assignment and use the bookmarklet to assign yourself (your a8c account) to the treatment group.

You will need to log in to the app with your a8c account to see the experiment while it is in staging (not launched to users yet).

Steps

  • Launch the app in a store with less than 3 products and tap the Add Product CTA
  • Create a template product
  • See that the preview button is enabled

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@Ecarrion Ecarrion added the feature: products onboarding Related to onboarding new users to manage products label Nov 11, 2022
@Ecarrion Ecarrion added this to the 11.2 milestone Nov 11, 2022
@peril-woocommerce
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 2 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 11, 2022

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8091-5b90ccb on your iPhone

If you need access to App Center, please ask a maintainer to add you.

Copy link
Contributor

@ealeksandrov ealeksandrov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

There are couple of failing tests to check:

  • testProductHasNoChangesFromEditActionsOfTheSameData
  • testObservablesFromUpdatingProductPasswordRemotely

return hasUnsavedChanges()
case .edit, .readonly:
return true
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

let commonDate = Date()
return emptyProduct.copy(date: commonDate, dateCreated: commonDate, dateModified: commonDate, dateOnSaleStart: commonDate, dateOnSaleEnd: commonDate) ==
product.copy(date: commonDate, dateCreated: commonDate, dateModified: commonDate, dateOnSaleStart: commonDate, dateOnSaleEnd: commonDate)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea!

@Ecarrion Ecarrion enabled auto-merge November 11, 2022 13:18
@Ecarrion Ecarrion merged commit b65edef into trunk Nov 11, 2022
@Ecarrion Ecarrion deleted the issue/8071-preview-new-template branch November 11, 2022 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: products onboarding Related to onboarding new users to manage products

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Product Preview: Fix previews for new template products

4 participants